<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>弓友之家</title>
    <link rel="stylesheet" href="css/mui.css" />
    <link rel="stylesheet" href="fonts/iconfont.css" />
    <link rel="stylesheet" href="css/style.css" />
    <style>
    	#rank_content{padding-top: 40px;}
    </style>
</head>
<body>
	<header class="mui-bar mui-bar-nav">
		<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		<h1 class="mui-title">积分排行榜</h1>
		<a class="mui-icon mui-icon-more-filled mui-pull-right shareBtn"></a>
	</header>
	<div class="mui-content">
		<style>
			.search{position: fixed; top: 44px; width: 100%; z-index: 999; background: #fff; padding: 10px; box-sizing: border-box;}
			.search label{font-size: 14px; color: #333; line-height: 30px; width: 40%; float: left; display: block;}
			.search select{width: 60%; height: 28px; float: right; margin-bottom: 0;padding: 0; padding-left: 10px; border: 1px solid #dedede !important;}
			.rank-title{top: 85px;}
			#rank_content{padding-top: 80px;}
		</style>
		<div class="search mui-clearfix">
			<label>选择要查询的年份</label>
			<select class="years">
			</select>
		</div>
		<style>
			.zanz-img .mui-col-xs-6{padding: 10px 10px 5px;}
			.zanz-img img{width: 100%;}
		</style>
		<div class="rank-title mui-clearfix">
			<a data-href="integralrank.html">个人年度排行榜</a>
			<a data-href="integralrank02.html" class="on">团队年度排行榜</a>
			<a data-href="rule.html">规则</a>
		</div>
		<div class="" id="rank_content">
			<div class="zanz-img mui-row">
				<div class="mui-col-xs-6"><img src="" class="img_per"/></div>
				<div class="mui-col-xs-6"><img src="" class="img_team"/></div>
			</div>
		    <div class="">
		        <ul class="mui-table-view">
		        </ul>
		    </div>
		</div>
	</div>
	<br />
	<!--分享-->
	<div class="shareWx mui-hidden"> 
		<ul class="mui-list-unstyled">
			<li class="tel"><a href="javascript:void(0)" onclick="shareWeixinMessage(1)">微信好友</a></li>
			<li class="qq"><a href="javascript:void(0)" onclick="shareWeixinMessage(2)">朋友圈</a></li>
		</ul>
		<button type="button" class="cancleShare">取消</button>
	</div>
	<script type="text/javascript" src="js/mui.min.js" ></script>
	<script type="text/javascript" src="js/jquery-1.8.3.min.js" ></script>
	<script type="text/javascript" src="js/common.js" ></script>
	<script type="text/javascript" charset="utf-8">
		var year=""; 
		mui.ajax(H_SRC+'/amier/index/sponsor',{
			data:{
				token:token
			},
			dataType:'json',
			type:'post',
			timeout:10000,             
			success:function(data){
				var dataurl=data.data;
				$(".img_per").attr("src",H_SRC+dataurl.img_personal)
				$(".img_team").attr("src",H_SRC+dataurl.img_team)
			},
			error:function(){
				
			}
		}) 
		
      	mui.init();
      	var tit="",des="",img="";
      	mui.ajax(H_SRC+'/amier/index/ranking',{
			data:{
				token:token,
				type:2,
				year:year
			},
			dataType:'json',//服务器返回json格式数据
			type:'post',//HTTP请求类型
			timeout:10000,//超时时间设置为10秒；            
			success:function(data){
				var dataurl=data.data;
				if(data.code == 401)
				{
					mui.openWindow({
						url:'login.html',
						id:'login.html'
					})
				}else if(data.code == 1) 
				{
					var dataurl=data.data;
					var html="";
					for(var i=0;i<dataurl.length;i++){
						html+='<li class="mui-table-view-cell"><a class="mui-row" data-id="'+dataurl[i].id+'"><div class="mui-col-xs-3 mui-text-center">'+(i+1)+'</div><div class="mui-col-xs-6 mui-ellipsis">'+dataurl[i].name+'</div><div class="mui-col-xs-3">'+dataurl[i].score+'积分</div></a></li>';
					} 
					$('.mui-table-view').html(html);
					var data1=new Date();
					var years="";
					for(var j=0;j<data.years.length;j++){
						years+='<option>'+data.years[j].year+'</option>';
					}
					$(".years").html(years);
					$(".years").change(function(){
						year=$(this).find("option:selected").val();
						result()
					})
					tit=data.share_msg.share_title;
					des=data.share_msg.share_desc;
					img=H_SRC+data.share_msg.share_pic;
				}else{ 
					mui.toast(data.msg);
				}
			},
			error:function(){
			}
		}) 
		function result(){
			mui.ajax(H_SRC+'/amier/index/ranking',{
				data:{
					token:token,
					type:2,
					year:year
				},
				dataType:'json',//服务器返回json格式数据
				type:'post',//HTTP请求类型
				timeout:10000,//超时时间设置为10秒；            
				success:function(data){
					var dataurl=data.data;
					if(data.code == 401)
					{
						mui.openWindow({
							url:'login.html',
							id:'login.html'
						})
					}else if(data.code == 1) 
					{
						var dataurl=data.data;
						var html="";
						for(var i=0;i<dataurl.length;i++){
							html+='<li class="mui-table-view-cell"><a class="mui-row" data-id="'+dataurl[i].id+'"><div class="mui-col-xs-3 mui-text-center">'+(i+1)+'</div><div class="mui-col-xs-6 mui-ellipsis">'+dataurl[i].name+'</div><div class="mui-col-xs-3">'+dataurl[i].score+'积分</div></a></li>';
						} 
						$('.mui-table-view').html(html);
					}else{ 
						mui.toast(data.msg);
					}
				},
				error:function(){
				}
			}) 
		}
		$(".rank-title").on("tap","a",function(){ 
      		var href=$(this).attr("data-href");
      		mui.openWindow({
				url:href,
				id:href,
				createNew:true,
				show: {
					autoShow: true,
					aniShow: 'slide-in-right',
					duration: 200
				}
			});
      	})
		$(".mui-table-view").on("tap","a",function(){ 
      		var mid=$(this).attr("data-id");
      		mui.openWindow({
				url:'integralrank-page02.html',
				id:'integralrank-page02.html',
				createNew:true,
				show: {
					autoShow: true,
					aniShow: 'slide-in-right',
					duration: 200
				},
				extras:{
					mid:mid
				}
			});
      	})
		
		function shareWeixinMessage(type){
			var type=type;
			if(type==1){
				var secne="WXSceneSession"
			}else{
				var secne="WXSceneTimeline"
			}
			sharewx.send( 
				{ 
					title:tit,
					content:des, 
					href:H_SRC+'/share_team',
					thumbs: [img], 
		        	pictures: [img], 
					extra:{scene:secne}
				}, 
				function(){
					mask.close();
					$(".shareWx").addClass("mui-hidden");
					mui.toast( "分享成功！" );
				}, function(e){
					mask.close();
					$(".shareWx").addClass("mui-hidden");
					mui.toast( "取消分享");
				}
			);
		}
    </script>
</body>
</html>